# -*- coding: utf-8 -*-
# __author__ = 'xxx'
# env
# function: 按时关闭 virtualbox 实例

# -*- coding:utf-8 -*-

'''
schedule.every(10).seconds.do(job) # 每10秒执行一次
schedule.every(10).minutes.do(job) # 每10分钟执行一次
schedule.every().hour.do(job) # 每小时执行一次
schedule.every().day.at("10:30").do(job) # 每天十点半执行
schedule.every(5).to(10).minutes.do(job) # 不理解
schedule.every().monday.do(job) # 每周一执行
schedule.every().wednesday.at("13:15").do(job) # 每周三13点15执行
schedule.every().minute.at(":17").do(job) # 不理解

https://github.com/dbader/schedule

'''

import os
import commands,time,schedule

def startvm():
  print("start this is ok running")
  os.system("startuse.bat")
  print(time.localtime())

def shutvm():
  print("shut this is ok running")
  os.system("shutdownuse.bat")
  print(time.localtime())


def schuse():

  #schedule.every().day.at("10:18").do(startvm)
  #schedule.every().day.at("10:22").do(shutvm)
  schedule.every().day.at("09:02").do(shutvm)
  schedule.every().day.at("09:12").do(shutvm)
  schedule.every().day.at("09:18").do(shutvm)
  schedule.every().saturday.at("09:22").do(startvm)
  schedule.every().sunday.at("09:22").do(startvm)
  schedule.every().day.at("18:10").do(startvm)
  schedule.every().day.at("21:10").do(startvm)
  schedule.every().day.at("22:10").do(startvm)

  #print(time.localtime())
  while True:
    schedule.run_pending()
    time.sleep(2)

schuse() 

#startvm() 
#time.sleep(200)
#shutvm()
#time.sleep(200)
